Skip to content

Conversation

@khalidhuseynov
Copy link
Member

@khalidhuseynov khalidhuseynov commented Oct 18, 2016

What is this PR for?

apply multi-tenancy for storage sync mechanism

What type of PR is it?

Bug Fix | Improvement

Todos

  • - broadcast on sync
  • - set permissions for pulled notes
  • - add test

What is the Jira issue?

ZEPPELIN-1561

How should this be tested?

Outline the steps to test the PR here.

Screenshots (if appropriate)

green CI

Questions:

  • Does the licenses files need update? no
  • Is there breaking changes for older versions? no
  • Does this needs documentation? no

@khalidhuseynov khalidhuseynov changed the title Improve/sync multiuser [Zeppelin-1561] Improve sync for multiuser environment Oct 18, 2016
Copy link
Contributor

@anthonycorbacho anthonycorbacho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for handeling this case, i added a comment please let me know what your think about it

}

private void makePrivate(String noteId, AuthenticationInfo subject) {
if (subject != null && !"anonymous".equals(subject.getUser())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about creating in AuthenticationInfo a new method called isAnonymous(AuthenticationInfo subject) and move the check inside?

something like

// In AuthenticationInfo.java
 private static final String ANONYMOUS = "anonymous";

 public static boolean isAnonymous(AuthenticationInfo subject) {
   if (subject != null ) {
     LOG.info("Subject is null assuming anonymous");
     return true;
   }
   return ANONYMOUS.equals(subject.getUser(); 
 }

//for the fun
public boolean isAnonymous() {
  return ANONYMOUS.equals(user);
}

//then here you can do something like this in makePrivate

if (AuthenticationInfo.isAnonymous(subject)) {
  // Add maybe meaningful log :)
  return;
}
NotebookAuthorization notebookAuthorization = NotebookAuthorization.getInstance();
Set<String> users = notebookAuthorization.getOwners(noteId);
users.add(subject.getUser());
notebookAuthorization.setOwners(noteId, users);
users = notebookAuthorization.getReaders(noteId);
users.add(subject.getUser());
notebookAuthorization.setReaders(noteId, users);
users = notebookAuthorization.getWriters(noteId);
users.add(subject.getUser());
notebookAuthorization.setWriters(noteId, users);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, can be reused to make anonymous consistent in usage over codebase. I'll change now

@khalidhuseynov
Copy link
Member Author

@anthonycorbacho addressed in d0a8c3c with some minor changes

LOG.info("No storages could be initialized, using default {} storage", defaultStorage);
initializeDefaultStorage(conf);
}
//syncOnStart();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see syncOnStart method called anywhere. So, i believe you commented the above line by mistake.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajarajan-g thanks for pointing to it. actually initial purpose was to delete it, but it was extracted into sub-function and commented out. addressed by deleting it in 1c11c2d

}
NotebookAuthorization notebookAuthorization = NotebookAuthorization.getInstance();
Set<String> users = notebookAuthorization.getOwners(noteId);
users.add(subject.getUser());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate why 'makePrivate()' routine, which is being used inside of sync() adds current user as a owner, reader, writer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, it sets it when pulling notes from secondary storage to your main one

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why it sets when pulling notes from secondary storage to the main one?

For example, what happen if a note permission has a user as a reader, but not as a writer and owner?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's pulling, that means there was no such a note in main storage and it's pulling new note from secondary storage. Thus, that new note not supposed to have previous owners, readers, writers. So generally it's same as creating note and only owner should be set. But I also set readers and writers in order other users don't see that new note (make it private).

@khalidhuseynov
Copy link
Member Author

@Leemoonsoo your comment makes sense if there's already existing acl for the note. addressed it with test under e41b9b9

@khalidhuseynov khalidhuseynov force-pushed the improve/sync-multiuser branch 3 times, most recently from b5d026c to 0355f26 Compare October 23, 2016 13:24
@khalidhuseynov
Copy link
Member Author

CI is green, ready for review

@anthonycorbacho
Copy link
Contributor

LGTM merging if no more discussion

@asfgit asfgit closed this in dfbea2e Oct 24, 2016
darionyaphet pushed a commit to darionyaphet/zeppelin that referenced this pull request Oct 27, 2016
### What is this PR for?
apply multi-tenancy for storage sync mechanism

### What type of PR is it?
Bug Fix | Improvement

### Todos
* [x] - broadcast on sync
* [x] - set permissions for pulled notes
* [x] - add test

### What is the Jira issue?
 [ZEPPELIN-1561](https://issues.apache.org/jira/browse/ZEPPELIN-1561)

### How should this be tested?
Outline the steps to test the PR here.

### Screenshots (if appropriate)
green CI

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Khalid Huseynov <[email protected]>

Closes apache#1537 from khalidhuseynov/improve/sync-multiuser and squashes the following commits:

b3e6ed3 [Khalid Huseynov] add userAndRoles
0f2ade7 [Khalid Huseynov] reformat style
bd1a44a [Khalid Huseynov] address comment + test
05afa2a [Khalid Huseynov] remove syncOnStart
b104249 [Khalid Huseynov] add isAnonymous
1a54cc0 [Khalid Huseynov] set perms for pulling notes - make them private
585a675 [Khalid Huseynov] reload, sync and broadcast on login
cd1c3fa [Khalid Huseynov] don't sync on start
pedrozatta pushed a commit to pedrozatta/zeppelin that referenced this pull request Oct 27, 2016
### What is this PR for?
apply multi-tenancy for storage sync mechanism

### What type of PR is it?
Bug Fix | Improvement

### Todos
* [x] - broadcast on sync
* [x] - set permissions for pulled notes
* [x] - add test

### What is the Jira issue?
 [ZEPPELIN-1561](https://issues.apache.org/jira/browse/ZEPPELIN-1561)

### How should this be tested?
Outline the steps to test the PR here.

### Screenshots (if appropriate)
green CI

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Khalid Huseynov <[email protected]>

Closes apache#1537 from khalidhuseynov/improve/sync-multiuser and squashes the following commits:

b3e6ed3 [Khalid Huseynov] add userAndRoles
0f2ade7 [Khalid Huseynov] reformat style
bd1a44a [Khalid Huseynov] address comment + test
05afa2a [Khalid Huseynov] remove syncOnStart
b104249 [Khalid Huseynov] add isAnonymous
1a54cc0 [Khalid Huseynov] set perms for pulling notes - make them private
585a675 [Khalid Huseynov] reload, sync and broadcast on login
cd1c3fa [Khalid Huseynov] don't sync on start
@khalidhuseynov khalidhuseynov deleted the improve/sync-multiuser branch November 14, 2016 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants